﻿using System.Collections.Generic;
using nRoute.SiteMaps;
using nRoute.ViewModels;

namespace nRoute.Samples.SiteMapModule.ViewModels
{
	public class OrdersViewModel : ViewModelBase
	{
		public OrdersViewModel()
		{
			LoadSiteMap();
		}

		public IEnumerable<SiteMapNode> SiteMapNodes { get; private set; }

#region Helpers

		private void LoadSiteMap()
		{
			// asking for them this way ensure they are loaded 
			nRoute.SiteMaps.SiteMapService.LoadSiteMap((s) =>
			{
				var _siteMapNode = nRoute.SiteMaps.SiteMapService.ResolveSiteMapNode("Orders");
				if (_siteMapNode != null)
				{
					this.SiteMapNodes = _siteMapNode.ChildNodes;
					NotifyPropertyChanged(() => SiteMapNodes);
				}
			});
		}

#endregion

	}
}